<?php

namespace Modules\Shop\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CategoryRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
    	$id=$this->route('category');
        return [
            'cname'=>'required|unique:categories,cname,'.$id
        ];
    }
	public function messages ()
	{
		return [
			'cname.required'=>'分类名称不能为空',
			'cname.unique'=>'分类名称已存在'
		];
	}

	/**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
